package com.free.wang.demo02.controller;

import com.free.wang.demo02.entity.Course;
import com.free.wang.demo02.service.CourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author admin
 * @Description 学生接口层
 * @date 2020-07-05 15:19:00
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @PostMapping(value = "/create")
    public String create(@RequestBody Course course) {
        this.courseService.insertSelective(course);
        return "SUCCESS";
    }

    @GetMapping(value = "/delete/{id}")
    public String delete(@PathVariable String id) {
        this.courseService.deleteByPrimaryKey(id);
        return "SUCCESS";
    }

    @PostMapping(value = "/update")
    public String update(@RequestBody Course course) {
        this.courseService.updateByPrimaryKeySelective(course);
        return "SUCCESS";
    }

    @GetMapping(value = "/page/{id}")
    public String page(@PathVariable String id) {
        this.courseService.selectByPrimaryKey(id);
        return "SUCCESS";
    }

}
